//
//  AppDelegate.m
//  01_Work
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate () <UITextFieldDelegate>
@property (nonatomic, strong) UIView *textFieldView;
@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    _window.rootViewController = [[ViewController alloc] init];
    
    UIImageView *backGroundImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backGroundImageView.backgroundColor = [UIColor redColor];
    UIImage *image = [UIImage imageNamed:@"welcome_2"];
    [backGroundImageView setImage:image];
    [_window addSubview:backGroundImageView];
    
    UIImageView *logoView = [[UIImageView alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 - 60, 100, 120, 200)];
    UIImage *logoImage = [UIImage imageNamed:@"logo_lagou"];
    [logoView setImage:logoImage];
    [backGroundImageView addSubview:logoView];
    
    self.textFieldView = [[UIView alloc] initWithFrame:CGRectMake(10, 350, backGroundImageView.frame.size.width - 20, 82)];
    self.textFieldView.layer.cornerRadius = 10;

    [_window addSubview:self.textFieldView];
    
    UITextField *idTextField = [[UITextField alloc] initWithFrame:CGRectMake(40, 0, self.textFieldView.frame.size.width - 40, 40)];
    idTextField.backgroundColor = [UIColor colorWithRed:57.0 / 255 green:55.0 / 255 blue:55.0 / 255 alpha:0.8];
    idTextField.delegate = self;
    [self.textFieldView addSubview:idTextField];
    UITextField *keyTextField = [[UITextField alloc] initWithFrame:CGRectMake(40, 42, self.textFieldView.frame.size.width - 40, 40)];
    keyTextField.backgroundColor = [UIColor colorWithRed:57.0 / 255 green:55.0 / 255 blue:55.0 / 255 alpha:0.8];
    keyTextField.delegate = self;
    [self.textFieldView addSubview:keyTextField];
    
    UIImageView *idImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    idImageView.backgroundColor = [UIColor blackColor];
    UIImage *idImage = [UIImage imageNamed:@"icon_username"];
    [idImageView setImage:idImage];
    [self.textFieldView addSubview:idImageView];
    
    UIImageView *keyImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 42, 40, 40)];
    keyImageView.backgroundColor = [UIColor blackColor];
    UIImage *keyImage = [UIImage imageNamed:@"icon_password"];
    [keyImageView setImage:keyImage];
    [self.textFieldView addSubview:keyImageView];
    // 设置弧度
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:idTextField.bounds byRoundingCorners:UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *idlayer = [CAShapeLayer layer];
    idlayer.frame = idTextField.bounds;
    idlayer.path = path.CGPath;
    idTextField.layer.mask = idlayer;
    
    UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:keyTextField.bounds byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *keyLayer = [CAShapeLayer layer];
    keyLayer.frame = idTextField.bounds;
    keyLayer.path = path1.CGPath;
    keyTextField.layer.mask = keyLayer;
    
    UIBezierPath *path2 = [UIBezierPath bezierPathWithRoundedRect:idImageView.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *idLa = [CAShapeLayer layer];
    idLa.frame = idImageView.bounds;
    idLa.path = path2.CGPath;
    idImageView.layer.mask = idLa;
    
    UIBezierPath *path3 = [UIBezierPath bezierPathWithRoundedRect:keyImageView.bounds byRoundingCorners:UIRectCornerBottomLeft cornerRadii:CGSizeMake(10, 10)];
    CAShapeLayer *keyLa = [CAShapeLayer layer];
    keyLa.frame = keyImageView.bounds;
    keyLa.path = path3.CGPath;
    keyImageView.layer.mask = keyLa;
    
    UIButton *logButton = [UIButton buttonWithType:UIButtonTypeSystem];
    logButton.frame = CGRectMake(10, 455, backGroundImageView.frame.size.width - 20 , 40);
    [backGroundImageView addSubview:logButton];
    logButton.backgroundColor = [UIColor colorWithRed:61.0 / 255 green:160.0 / 255 blue:115.0 / 255 alpha:0.8];
    [logButton setTitle:@"登录" forState:UIControlStateNormal];
    [logButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    logButton.layer.cornerRadius = 5;
    
    UIButton *forgetButton = [UIButton buttonWithType:UIButtonTypeSystem];
    forgetButton.frame = CGRectMake(7, 510, 80, 40);
    [forgetButton setTitle:@"忘记密码" forState:UIControlStateNormal];
    [forgetButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    forgetButton.titleLabel.font = [UIFont systemFontOfSize:18];
    [backGroundImageView addSubview:forgetButton];
    
    UIButton *regButton = [UIButton buttonWithType:UIButtonTypeSystem];
    regButton.frame = CGRectMake(10, 540, backGroundImageView.frame.size.width - 20, 40);
    [regButton setTitle:@"现在注册拉勾" forState:UIControlStateNormal];
    [regButton setTitleColor:[UIColor colorWithRed:61.0 / 255 green:160.0 / 255 blue:115.0 / 255 alpha:0.8] forState:UIControlStateNormal];
    regButton.titleLabel.font = [UIFont systemFontOfSize:20];
    regButton.titleLabel.font = [UIFont boldSystemFontOfSize:22];
    [backGroundImageView addSubview:regButton];
    
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(10, 610, backGroundImageView.frame.size.width / 2 - 30, 2)];
    lineView1.backgroundColor = [UIColor whiteColor];
    [backGroundImageView addSubview:lineView1];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 - 4, 593, 40, 30)];
    label.text = @"or";
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:20];
    [backGroundImageView addSubview:label];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(backGroundImageView.frame.size.width / 2 + 30, 610, backGroundImageView.frame.size.width / 2 - 40, 2)];
    lineView2.backgroundColor = [UIColor whiteColor];
    [backGroundImageView addSubview:lineView2];
    
    UIButton *strollButton = [UIButton buttonWithType:UIButtonTypeSystem];
    strollButton.frame = CGRectMake(backGroundImageView.frame.size.width / 2 - 75, 640, 160, 40);
    [strollButton setTitle:@"随便逛逛>" forState:UIControlStateNormal];
    [strollButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    strollButton.titleLabel.font = [UIFont systemFontOfSize:20];
    [backGroundImageView addSubview:strollButton];
    
    return YES;
} 

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField endEditing:YES];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
